package com.morehair.service.wx.impl;

import com.morehair.bean.pojo.User;
import com.morehair.bean.vo.wx.UserIndexVo;
import com.morehair.mapper.OrderMapper;
import com.morehair.service.wx.WxUserService;
import com.morehair.utils.GetNowUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Description:
 * Date: 2021/6/8
 * Time: 18:46
 * author: zhang wei
 */
@Service
@Transactional
public class WxUserServiceImpl implements WxUserService {

    @Autowired
    OrderMapper orderMapper;
    @Override
    public UserIndexVo getUserIndex() {
        User user = GetNowUser.getUser();
        Integer userId = user.getId();
        int unPaid = orderMapper.selectUnPaidByUserId(userId);
        int unShip = orderMapper.selectUnShipByUserId(userId);
        int unRecv = orderMapper.selectUnRecvByUserId(userId);
        int unComment = orderMapper.selectUnCommentByUserId(userId);
        UserIndexVo userIndexVo = new UserIndexVo();
        UserIndexVo.UserIndexOrder userIndexOrder = new UserIndexVo.UserIndexOrder();

        userIndexOrder.setUnpaid(unPaid);
        userIndexOrder.setUnship(unShip);
        userIndexOrder.setUnrecv(unRecv);
        userIndexOrder.setUncomment(unComment);

        userIndexVo.setOrder(userIndexOrder);

        return userIndexVo;
    }


}
